public class A {
    #include <iostream>
    using namespace std;
#include <set>

    int main()
    {
        int t = 0;
        cin >> t;
        while(t--)
        {
            int n = 0;
            cin >> n;
            string s;
            cin >> s;
            set<string> hash;
            for(int i = 0; i < n - 1; i++)
            {
                string tmp = "";
                tmp += s[i];
                tmp += s[i+1];
                hash.insert(tmp);
            }
            cout << hash.size() << endl;
        }
        return 0;
    }
}
